package tpo.lmhconsumer.lmhconsumer.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import dto.Dto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tpo.lmhconsumer.lmhconsumer.service.LabelService;

import java.util.Map;

/**
 * 标签
 */
@RestController
public class LabelController {
    @Autowired
    LabelService labelService;
    /**
     * @param map
     * @return
     */
    @RequestMapping("getLabel")
    @HystrixCommand(fallbackMethod = "rd_map")
    Dto getLabel(@RequestBody Map map){
        return labelService.getLabel(map);
    }

    /**
     * @param map
     * @return
     */
    @RequestMapping("delLabel")
    @HystrixCommand(fallbackMethod = "rd_map")
    Dto delLabel(@RequestBody Map map){
        return labelService.delLabel(map);
    }

    /**
     * @param map
     * @return
     */
    @RequestMapping("addLabel")
    @HystrixCommand(fallbackMethod = "rd_map")
    Dto addLabel(@RequestBody Map map){
        return labelService.addLabel(map);
    }

    /**
     * @param map
     * @return
     */
    @RequestMapping("updateLabel")
    @HystrixCommand(fallbackMethod = "rd_map")
    Dto updateLabel(@RequestBody Map map){
        return labelService.updateLabel(map);
    }

    private Dto rd_map(Map map){
        Dto dto=new Dto();
        dto.setMsg("熔断");
        return dto;
    }

}
